/****************************************************************************************
**  Filename :  ThinkTech_UART.h
**  Abstract :  This file implements SPI function.
**  By       :  钟伟
**  Date     :  2018-12-26 
**  Changelog:1.First Create
*****************************************************************************************/
#ifndef _TKT_UART_H
#define _TKT_UART_H
/*****************************************************************************************
									Includes
*****************************************************************************************/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
/*****************************************************************************************
								Macro definitions
*****************************************************************************************/
#define USART3_BaudRate					460800
#define USART3_REC_LEN  				1024  
/*****************************************************************************************
								Typedef definitions
*****************************************************************************************/
typedef struct 
{
	uint8_t startByte;                  //!< #kFramingPacketStartByte

	uint8_t packetType;                 //!< Framing packet type
}FramingHeader;

typedef struct 
{
	FramingHeader header;            	//!< Framing packet header

	uint16_t length;                   	//!< Number of data bytes that follow

	uint16_t reserved;                 	//!< Reserved half word

	uint16_t crc16;                    	//!< CRC-16 of data packet header and data
}FramingDataPacket;

typedef struct 
{
	FramingDataPacket dataPacket;    	//!< Framing packet header

	uint8_t data[512];            		//!< Payload.
}SerialFramingPacket;

typedef struct 
{
	uint32_t length; 
	uint8_t chipType;
	uint8_t check;
	uint8_t automatic;
	uint8_t run;
	uint32_t burnNumber; 
	uint32_t uidEn; 
	uint8_t uidStart[12];
	uint8_t uidEnd[12];
	uint8_t otpOption;
	uint8_t firmwareNumber;
	uint8_t reserve[2];
	uint8_t firmwareInformation[40];  
}ConfigInformation;
/*****************************************************************************************
							Global variables and functions
*****************************************************************************************/	
extern ConfigInformation readConfigInformation;

void usart3_init(void);
void wait_write_bin(void);
void r_timeout(void);
//----------------------------------------------------------------------------------------
#endif
/***********************************END OF FILE*******************************************/



